package june.test_6_11;

public class TestMain2 {
    public static void main(String[] args) {
        int[][] arr = {{1,-1},{-1,1}};
        arr[0][1] = 0;
        System.out.println(returnResult(arr, 0, 1, 2, 2));
    }
    private static int returnResult(int[][] arr,int i,int j,int m,int n) {
        if(i >= m || j >= n) {
            return 0;
        }
        if(i < 0 || j < 0) {
            return 0;
        }
        if(arr[i][j] == -1) {
            return 0;
        }
        System.out.println(arr[i][j]);
        return arr[i][j] + returnResult(arr,i - 1,j,m,n)
                + returnResult(arr,i + 1,j,m,n)
                + returnResult(arr,i ,j - 1,m,n)
                + returnResult(arr,i ,j + 1,m,n);
    }
}
